<template>
  <div class="set">
    <div v-if="ts" class="tishi">
      <i class="iconfont">&#xe615;</i>
      <p>下单成功，正在跳转首页</p>
    </div>
    <div class="bottom">
      <p>总价：￥{{ zj }}</p>
      <span @click="tj(), tijiao2()">提交</span>
    </div>
    <div class="type">
      <span class="iconfont" @click="goto()">&#xe779;</span>
      结算
    </div>
    <div class="dizhi" @click="shdz1()">
      <p>{{shdz.name}}</p>
      <p>收货地址：{{shdz.sh}}</p>
      <span>{{shdz.dh}}</span>
      <span class="iconfont"> &#xe775; </span>
    </div>
    <div class="fs">
      <p>支付方式</p>
      <span class="iconfont">线上支付&#xe775;</span>
    </div>
    <div class="xinxi">
      <p>平台自营</p>
      <div class="sp" v-for="item in tijiaodd">
        <div class="left">
          <img :src="item.img" alt="" />
        </div>
        <div class="right">
          <p>{{ item.name }}</p>
          <div class="gg">
            <span v-if="item.gg">规格:{{ item.gg }}</span>
            <span v-if="item.ys">颜色:{{ item.ys }}</span>
          </div>
          <div class="bot">
            <p>x{{ item.sl }}</p>
            <span>￥:{{ item.jg * item.sl }}</span>
          </div>
        </div>
      </div>
    </div>
    <div class="yf">
      <p>运费</p>
      <span class="iconfont">￥0</span>
    </div>
    <div class="bz">
      <p>买家留言</p>
      <input type="text" name="" id="" placeholder="请填写备注" />
    </div>
  </div>
</template>
<style lang="scss" scoped>
.set {
  background-color: rgb(235, 235, 235);
  padding-bottom: 200px;
  .tishi {
    position: fixed;
    width: 40%;
    background-color: black;
    top: 40%;
    left: 30%;
    z-index: 999999;
    text-align: center;
    i {
      color: white;
      font-size: 40px;
      line-height: 60px;
    }
    p {
      padding-bottom: 15px;
      color: white;
      font-size: 14px;
    }
  }
  .bottom {
    width: 100%;
    height: 62px;
    position: fixed;
    z-index: 999999;
    background-color: white;
    border-top: 1px solid #ccc;
    bottom: 0px;
    p {
      color: red;
      font-size: 16px;
      line-height: 62px;
      margin-left: 15px;
    }
    span {
      position: absolute;
      right: 0;
      display: block;
      top: 0px;
      height: 62px;
      text-align: center;
      font-size: 16px;
      line-height: 62px;
      width: 150px;
      color: white;
      background-color: red;
    }
  }
  .type {
    text-align: center;
    line-height: 50px;
    font-size: 16px;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 99999;
    border-bottom: 1px solid #ccc;
    font-weight: bold;
    color: rgb(116, 116, 116);
    text-align: center;
    background-color: white;
    span {
      position: absolute;
      display: block;
      height: 50px;
      width: 40px;
    }
  }
  .dizhi {
    padding: 15px;
    margin-top: 50px;
    position: relative;
    background-color: white;
    border-bottom: 3px dotted rgb(255, 104, 104);
    p {
      line-height: 30px;
      font-size: 16px;
      color: rgb(82, 82, 82);
    }
    span {
      top: 15px;
      position: absolute;
      font-size: 15px;
      right: 20px;
      color: rgb(82, 82, 82);
    }
    span:nth-of-type(2) {
      top: 35px;
      font-size: 17px;
      right: 0;
    }
  }
  .fs {
    margin-top: 10px;
    padding: 15px;
    background-color: white;
    position: relative;
    p {
      color: rgb(82, 82, 82);
      font-size: 16px;
    }
    span {
      color: rgb(82, 82, 82);
      right: 10px;
      top: 15px;
      position: absolute;
      font-size: 16px;
    }
  }
  .xinxi {
    margin-top: 10px;
    padding: 0 15px;
    background-color: white;
    > p {
      color: rgb(82, 82, 82);
      font-size: 16px;
      border-bottom: 1px solid #ccc;
      padding: 15px 0;
    }
    .sp {
      padding: 10px 0;
      display: flex;
      border-bottom: 1px solid #ccc;
      .left {
        width: 90px;
        height: 90px;
        img {
          width: 90px;
          max-height: 90px;
          margin: 0 auto;
        }
      }
      .right {
        margin: 0 10px;
        > p {
          white-space: nowrap;
          text-overflow: ellipsis;
          overflow: hidden;
          color: rgb(82, 82, 82);
          line-height: 20px;
          font-size: 15px;
        }
        .gg {
          margin-top: 5px;
          span {
            color: rgb(82, 82, 82);
            font-size: 12px;
          }
        }
        .bot {
          margin-top: 25px;
          position: relative;
          p {
            color: rgb(82, 82, 82);
            font-size: 14px;
          }
          span {
            position: absolute;
            right: 0;
            font-size: 14px;
            color: red;
            top: 0;
          }
        }
      }
    }
  }
  .yf {
    margin-top: 10px;
    padding: 15px;
    background-color: white;
    position: relative;
    p {
      color: rgb(82, 82, 82);
      font-size: 16px;
    }
    span {
      color: red;
      right: 10px;
      top: 15px;
      position: absolute;
      font-size: 16px;
    }
  }
  .bz {
    margin-top: 10px;
    padding: 15px;
    display: flex;
    position: relative;
    background-color: white;
    p {
      color: rgb(82, 82, 82);
      font-size: 16px;
    }
    input {
      color: rgb(82, 82, 82);
      margin-left: 10px;
      font-size: 16px;
      margin-top: -2px;
      border: none;
      outline-style: none;
    }
  }
}
</style>
<script>
import { mapState, mapMutations } from "vuex";
export default {
  name: "settlement",
  data() {
    return {
      zj: 0,
      ts: false,
    };
  },
  methods: {
    goto() {
      this.$router.go(-1);
      this.$store.state.tijiaodd = [];
    },
    tj() {
      this.ts = true;
      let _this = this;
      let time = setTimeout(function () {
        _this.ts = false;
        _this.$router.push({ path: "/home/index" });
      }, 1000);
    },
    shdz1(){
      this.$router.push({path:'/home/address'})
    },
    ...mapMutations(["tijiao2"]),
  },
  computed: {
    ...mapState(["tijiaodd",'dz','mrdz','shdz']),
  },
  mounted() {
    if(!this.shdz.name){
      this.$store.state.shdz=this.dz[this.mrdz]
    }
    for (let i = 0; i < this.tijiaodd.length; i++) {
      this.zj += this.tijiaodd[i].jg * this.tijiaodd[i].sl;
    }
  },
};
</script>